#ifndef HARD_CODDED_DATA_INPUT_BOX_H_JM_20120626
#define HARD_CODDED_DATA_INPUT_BOX_H_JM_20120626

// ##
#include "InputBox.h"
#include "../../common/Utils.h"

namespace jm4bbx {

	/**
	* Box zabezpecujuci vstup dat do modelu vypoctu, ktory vsak nennacita data 
	* z externeho zdroja ale ma data v sebe napevno zadane.
	*
	*/
	template</*class BoxDescriptor,*/ int ROWS = 10, int COLUMNS = 1>
	class HardCodedDataInputBox : public InputBox/*<BoxDescriptor>*/ {
	public:
		//typedef InputBoxDescriptor BoxIO;

		static const int ROWS_COUNT = ROWS;
		static const int COLUMNS_COUNT = COLUMNS;


		HardCodedDataInputBox(bobox::box_id_type id, bobox::box_tid_type tid, 
			bobox::request* req, const bobox::parameters& params) 
			: InputBox(id, tid, req, params) {
		}

		virtual size_t getColumnSize() const override {
			return ROWS_COUNT;
		};

	protected:

		virtual void loadData() override {
			for (size_t i = 0; i < COLUMNS_COUNT; ++i) {
				init(i);
			}
		};

		virtual void init(const size_t& columnIndex) = 0;
	private: 
	};

	//struct HardCodedIntegerDataInputBoxDescriptor : public InputBoxDescriptor {
	//	static const char* BOX_ID;
	//};


	template</*class BoxDescriptor,*/ int ROWS, int COLUMNS>
	class HardCodedIntegerDataInputBox :
		public HardCodedDataInputBox</*BoxDescriptor,*/ ROWS, COLUMNS> {
	public:

		HardCodedIntegerDataInputBox(bobox::box_id_type id, 
			bobox::box_tid_type tid, bobox::request* req, 
			const bobox::parameters& params) 
			: HardCodedDataInputBox(id, tid, req, params) { }

	protected:
		void init(const size_t& colIndex) override {
			for (size_t i = 0; i < ROWS; ++i) {
				if (inputSpecification_ == "A") {
					get_data<bobox::int_policy>(columnType(colIndex))[i] = i*2;
				}
				else if (inputSpecification_ == "B") {
					get_data<bobox::int_policy>(columnType(colIndex))[i] = i%4 + 1;
				}
				else {
					get_data<bobox::int_policy>(columnType(colIndex))[i] = i;
				}
			}
		}

	};

	//struct HardCodedStringDataInputBoxDescriptor : public InputBoxDescriptor {
	//	static const char* BOX_ID;
	//};

	template</*class BoxDescriptor,*/int ROWS, int COLUMNS>
	class HardCodedStringDataInputBox : 
		public HardCodedDataInputBox</*BoxDescriptor, */
			ROWS, COLUMNS> {
	public: 
		HardCodedStringDataInputBox(bobox::box_id_type id, 
			bobox::box_tid_type tid, bobox::request* req, 
			const bobox::parameters& params) 
			: HardCodedDataInputBox(id, tid, req, params) { }

	protected:
		void init(const size_t& columnIndex) override {

			for (size_t i = 0; i < ROWS; ++i) {

				if (inputSpecification_ == "A") {
					get_data<bobox::string_policy>(
						columnType(columnIndex))[i] = 
							utils_jm::toString(i*2);
				}
				else if (inputSpecification_ == "B") {
					get_data<bobox::string_policy>(
						columnType(columnIndex))[i] = 
						utils_jm::toString(i%4 + 1);
				}
				else {
					get_data<bobox::string_policy>(
						columnType(columnIndex))[i] = 
						utils_jm::toString(i);
				}

			}
		}
	};
} // namespace jm4bbx

#endif
